package com.yidong.laidian.laidian.util;


import com.yidong.laidian.laidian.enums.ResultEnum;
import com.yidong.laidian.laidian.vo.ResultVO;

public class ResultVoUtils {
    public static ResultVO<Object> success(Object object) {
        ResultVO<Object> resultVO = new ResultVO<>();
        resultVO.setCode(0);
        resultVO.setMsg("成功");
        resultVO.setData(object);

        return resultVO;
    }

    public static ResultVO<Object> success() {
        return success(null);
    }

    public static ResultVO<Object> error(int code, String msg) {
        ResultVO<Object> resultVO = new ResultVO<>();
        resultVO.setCode(code);
        resultVO.setMsg(msg);

        return resultVO;

    }

    public static ResultVO<Object> error(ResultEnum resultEnum) {
        ResultVO<Object> resultVO = new ResultVO<>();
        resultVO.setCode(resultEnum.getCode());
        resultVO.setMsg(resultEnum.getMessage());

        return resultVO;

    }

}
